package com.example.app1

import android.content.res.Resources
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.util.TypedValue

val Float.dp: Float
    get() {
        return TypedValue.applyDimension(
            TypedValue.COMPLEX_UNIT_DIP,
            this,
            Resources.getSystem().displayMetrics
        )
    }


val Int.dp: Float get() = this.toFloat().dp

fun getBitmap(resources: Resources, resId: Int): Bitmap {
    val options = BitmapFactory.Options()
    options.inJustDecodeBounds = true
    BitmapFactory.decodeResource(resources, resId, options)
    options.inDensity = options.outWidth
    options.inTargetDensity = 200.dp.toInt()
    options.inJustDecodeBounds = false
    return BitmapFactory.decodeResource(resources, resId, options)
}
